package com.csdj.questions.service;

import com.csdj.questions.entity.Answer;
import com.csdj.questions.mapper.AnswerMapper;
import com.csdj.questions.service.IAnswerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 回答表 服务实现类
 * </p>
 *
 * @author 刘宇
 * @since 2022-03-08
 */
@Service
public class AnswerService extends ServiceImpl<AnswerMapper, Answer> implements IAnswerService {
    @Resource
    private AnswerMapper answerMapper;
    /**
     *  连表模糊查询，answer 和 t_question 和 article  的连表
     * @return
     */
    @Override
    public List<Map<String, Object>> selectLike(String quesName,String articleName) {
        List<Map<String, Object>> list = answerMapper.selectLike(quesName,articleName);
        return list;
    }

    /**
     * 根据问题id 查询 点赞的次数
     * @param quesId
     * @return
     */
    @Override
    public int selectCount(String quesId) {
        int count = answerMapper.selectCount(quesId);
        return count;
    }
}
